//
//  LaundryTheOrderDetailsSecondTableViewCell.m
//  BaseFrame
//
//  Created by 吕金状 on 2017/8/17.
//  Copyright © 2017年 com.mxh. All rights reserved.
//

#import "LaundryTheOrderDetailsSecondTableViewCell.h"

@interface LaundryTheOrderDetailsSecondTableViewCell ()

Strong UILabel *titleLabel;
Strong UIView *lineView;
Strong UILabel *contentLabel;
Strong UIView *line1View;

@end

@implementation LaundryTheOrderDetailsSecondTableViewCell

- (id)initWithCellIdentifier:(NSString *)cellID{
    self = [super initWithCellIdentifier:cellID];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _titleLabel  = [[UILabel alloc]init];
        _titleLabel.font = DEF_FontSize_14;
        _titleLabel.textColor = getColor(textColor);
        [self.contentView addSubview:_titleLabel];
        
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = getColor(dividerColor);
        [self.contentView addSubview:_lineView];
        
        _contentLabel  = [[UILabel alloc]init];
        _contentLabel.font = DEF_FontSize_14;
        _contentLabel.textColor = getColor(textColor);
        [self.contentView addSubview:_contentLabel];
        
        _line1View = [[UIView alloc]init];
        _line1View.backgroundColor = getColor(dividerColor);
        [self.contentView addSubview:_line1View];
        
        [self layoutFrame];
    }
    return self;
}

- (void)layoutFrame{
    __weak __typeof(self)weakSelf = self;
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10 / WIDTH_5S_SCALE);
        make.top.mas_equalTo(0);
        make.height.mas_equalTo(30 / WIDTH_5S_SCALE);
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10 / WIDTH_5S_SCALE);
        make.top.mas_equalTo(30 / WIDTH_5S_SCALE);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 20 / WIDTH_5S_SCALE, 0.5));
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10 / WIDTH_5S_SCALE);
        make.top.mas_equalTo(30 / WIDTH_5S_SCALE + 0.5);
        make.height.mas_equalTo(30 / WIDTH_5S_SCALE);
        make.width.mas_equalTo(SCREEN_WIDTH - 20 / WIDTH_5S_SCALE);
    }];
    
    [self.line1View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0 / WIDTH_5S_SCALE);
        make.top.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 0 / WIDTH_5S_SCALE, 0.5));
    }];
}

- (void)setModel:(NSDictionary *)model{
    _model = model;
    
    NSMutableAttributedString *attStr1 = [NSMutableAttributedString new];
    NSTextAttachment *seeAtt1 = [NSTextAttachment new];
    if (self.indexPath.row == 2 ) {
        seeAtt1.bounds = CGRectMake(0, -2 / WIDTH_5S_SCALE, 10 / WIDTH_5S_SCALE, 13 / WIDTH_5S_SCALE);
    }else{
        seeAtt1.bounds = CGRectMake(0, -2 / WIDTH_5S_SCALE, 12 / WIDTH_5S_SCALE, 12 / WIDTH_5S_SCALE);
    }
    
    seeAtt1.image = [UIImage imageNamed:model[@"image"]];
    
    [attStr1 appendAttributedString:[NSAttributedString attributedStringWithAttachment:seeAtt1]];
    [attStr1 appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"  %@",model[@"title"]]]];
    self.titleLabel.attributedText = attStr1;
    
    if (self.indexPath.row != 0) {
        self.contentLabel.text = model[@"content"];
    }else{
        NSMutableAttributedString *attStr2 = [NSMutableAttributedString new];
        [attStr2 appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"  %@",model[@"title"]]]];
        NSTextAttachment *seeAtt2 = [NSTextAttachment new];
        seeAtt2.bounds = CGRectMake(5 / WIDTH_5S_SCALE,  0 / WIDTH_5S_SCALE, 10 / WIDTH_5S_SCALE, 10 / WIDTH_5S_SCALE);
        seeAtt2.image = [UIImage imageNamed:@"prCode_nor"];
        [attStr2 appendAttributedString:[NSAttributedString attributedStringWithAttachment:seeAtt2]];
        self.contentLabel.attributedText = attStr2;
    }
}

@end
